package vip.xiaonuo.modular.manage.order.controller;

import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.manage.order.entity.BusinessOrderFile;
import vip.xiaonuo.modular.manage.order.param.BusinessOrderFileParam;
import vip.xiaonuo.modular.manage.order.service.IBusinessOrderFileService;

import javax.annotation.Resource;

/**
 * BusinessOrderFileController
 *
 * @author JackLee
 * 2022/9/7 15:38
 */
@RestController
public class BusinessOrderFileController {
    @Resource
    private IBusinessOrderFileService businessOrderFileService;

    @PostMapping("/businessOrder/add")
    @BusinessLog(title = "新增订单数据文件", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody BusinessOrderFile orderFile) {
        return new SuccessResponseData(businessOrderFileService.add(orderFile));
    }

    @GetMapping("/businessOrder/parse/view/{id}")
    public ResponseData parseForView(@PathVariable("id") Long id) {
        return new SuccessResponseData(businessOrderFileService.parseFileForView(id));
    }

    @GetMapping("/businessOrder/page")
    @BusinessLog(title = "分页查询订单数据文件", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(BusinessOrderFileParam param) {
        return new SuccessResponseData(businessOrderFileService.page(param));
    }
}
